package com.prs.crm.action.document;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.document.DraftPoint;
import com.prs.crm.service.document.DraftPointService;

public class DraftPointAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private DraftPoint draftPoint;
	private DraftPointService draftPointService;
	private PaginationSupport pagination;
	private Integer[] ids;
	public DraftPoint getDraftPoint() {
		return draftPoint;
	}
	public void setDraftPoint(DraftPoint draftPoint) {
		this.draftPoint = draftPoint;
	}
	public DraftPointService getDraftPointService() {
		return draftPointService;
	}
	public void setDraftPointService(DraftPointService draftPointService) {
		this.draftPointService = draftPointService;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	@Action("listDraftPoint")
	public String listDraftPoint(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(DraftPoint.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getDraftPointService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	
	@Action("editDraftPoint")
	public String editDraftPoint(){
			return SUCCESS;
	}
	
	@Action(value = "saveDraftPoint", results = {
			@Result(name = "success", type = "redirect", location = "listDraftPoint"),
			@Result(name = "error", type = "chain", location = "editDraftPoint") })
	public String saveDraftPoint(){
		this.getDraftPointService().save(draftPoint);
		return SUCCESS;
	}
	@Action(value = "removeDraftPoint", results = {
			@Result(name = "success", type = "redirect", location = "listDraftPoint"),
			@Result(name = "error", type = "chain", location = "listDraftPoint") })
	public String removeDraftPoint(){
		if (ids==null) {
			this.setPrompt("请选择一行！");
			return ERROR;
		}
		this.getDraftPointService().batchRemove(ids);
		return SUCCESS;
	}
}
